<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>nginx</title>
</head>

<body>
  <button id="proxy">proxy代理</button>
  <button id="fetch">未进行代理</button>
  <script>

    /* nginx */
    document.getElementById('proxy').addEventListener('click', async () => {
      const data = await fetch('http://localhost:8080/API')
        .then(response => response.json());
        console.log('nginx反向代理', data)
    });

    /* fetch */
    document.getElementById('fetch').addEventListener('click', async () => {
      const data = await fetch('http://localhost:10000')
        .then(response => response.json());
    });
  </script>
</body>

</html>